<template>
  <div id="app"> 
      <h1>根组件</h1>
      <span>库存总数：</span>
      <input type="text" v-model="num">
      <div style="border:1px solid black; width: 300px;">
         <AddItem></AddItem>
      </div>
      <hr>
      <div style="border: 1px solid black;width: 300px;">
        <SubItem></SubItem>
      </div>
      <div>
        
      </div>
  </div> 
</template>

<script>
import AddItem from '@/components/AddItem.vue'
import SubItem from '@/components/SubItem.vue'
export default {
  name: 'App',
  components:{
    AddItem,
    SubItem
  },
  computed:{
    num:{
      get(){
        return this.$store.state.count
      },
      set(val){
        this.$store.commit('setCount',val)
      }
    }
  },
  data(){
    return{}
  },
  methods:{

  }
}
</script>

<style>
 #app{
  width: 300px;
  margin: 20px auto;
  border: 1px solid #ccc;
  padding: 4px;
  }
</style>
